package com.ruoyi.oa.controller;

import java.util.List;

import com.ruoyi.oa.domain.OaFileLog;
import com.ruoyi.oa.service.IOaFileLogService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件操作Controller
 * 
 * @author luguanqing
 * @date 2022-02-09
 */
@RestController
@RequestMapping("/oa/filelog")
public class OaFileLogController extends BaseController
{
    @Autowired
    private IOaFileLogService oaFileLogService;

    /**
     * 查询文件操作列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OaFileLog oaFileLog)
    {
        startPage();
        List<OaFileLog> list = oaFileLogService.selectOaFileLogList(oaFileLog);
        return getDataTable(list);
    }

    /**
     * 导出文件操作列表
     */
    @Log(title = "文件操作", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OaFileLog oaFileLog)
    {
        List<OaFileLog> list = oaFileLogService.selectOaFileLogList(oaFileLog);
        ExcelUtil<OaFileLog> util = new ExcelUtil<OaFileLog>(OaFileLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取文件操作详细信息
     */
    @GetMapping(value = "/{fileId}")
    public AjaxResult getInfo(@PathVariable("fileId") String fileId)
    {
        return AjaxResult.success(oaFileLogService.selectOaFileLogById(fileId));
    }

    /**
     * 新增文件操作
     */
    @Log(title = "文件操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaFileLog oaFileLog)
    {
        return toAjax(oaFileLogService.insertOaFileLog(oaFileLog));
    }

    /**
     * 修改文件操作
     */
    @Log(title = "文件操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaFileLog oaFileLog)
    {
        return toAjax(oaFileLogService.updateOaFileLog(oaFileLog));
    }

    /**
     * 删除文件操作
     */
    @Log(title = "文件操作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fileIds}")
    public AjaxResult remove(@PathVariable String[] fileIds)
    {
        return toAjax(oaFileLogService.deleteOaFileLogByIds(fileIds));
    }
}
